<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4">
<head>
    <meta charset="utf-8">
    <title>基本资料</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" th:href="@{/lib/layui-v2.6.3/css/layui.css}" media="all">
    <link rel="stylesheet" th:href="@{/css/public.css}" media="all">
    <style>
        .layui-form-item .layui-input-company {width: auto;padding-right: 10px;line-height: 38px;}
    </style>
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">

        <div class="layui-form layuimini-form">

            <input autocomplete="off" class="layui-input" name="userId" th:value="${user.userId}"  type="hidden">

            <div class="layui-form-item">
                <label class="layui-form-label required">原密码</label>
                <div class="layui-input-block">
                    <input type="password" name="userPassword" lay-verify="required" lay-reqtext="原密码不可为空" placeholder="请输入原密码" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label required">新密码</label>
                <div class="layui-input-block">
                    <input type="password" name="userNewPassword" lay-verify="required" lay-reqtext="新密码不可为空" placeholder="请输入新密码" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label required">确认密码</label>
                <div class="layui-input-block">
                    <input type="password" name="userCheckPassword" lay-verify="required" lay-reqtext="确认密码不可为空" placeholder="请再次输入新密码" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
                </div>
            </div>
        </div>
    </div>
</div>
<script th:src="@{/lib/layui-v2.6.3/layui.js}" charset="utf-8"></script>
<script th:src="@{/js/lay-config.js?v=1.0.4}" charset="utf-8"></script>
<script th:inline="javascript">
    layui.use(['form','miniTab','upload'], function () {
        var $ = layui.jquery,
            form = layui.form,
            layer = layui.layer,
            upload = layui.upload,
            miniTab = layui.miniTab;

        //监听提交
        form.on('submit(saveBtn)', function (data) {
            var datas = data.field;
            var index = layer.alert("确认提交？", {
                title: '提示'
            }, function () {
                $.ajax({
                    url: '/user/updateUserPassword',
                    type: "POST",
                    data: datas,
                    success: function (data) {
                        if (data.code == 200) {
                            layer.alert(data.message, {
                                title: "提示",
                            }, function () {
                                // 关闭弹出层
                                layer.close(index);
                                var iframeIndex = parent.layer.getFrameIndex(window.name);
                                layer.close(iframeIndex);
                                window.location.reload();
                            })
                        } else {
                            layer.alert(data.message, {
                                title: "提示",
                            }, function () {
                                // 关闭弹出层
                                layer.close(index);
                                var iframeIndex = parent.layer.getFrameIndex(window.name);
                                layer.close(iframeIndex);
                                window.location.reload();
                            })
                        }
                    }
                });
                return false;
            });
        });
    });
</script>
</body>
</html>